﻿using UnityEngine;
using System.Collections;

public class CloudManager : MonoBehaviour {
	
	public float cloudTime = 5f;		// The amount of time between each spawn.
	public float cloudDelay = 2f;
	public GameObject[] enemies;
	public Rigidbody2D backgroundProp;	
	void Start () {
		InvokeRepeating("AddCloud", cloudDelay, cloudTime);
	}
	
	// Update is called once per frame
	void Update () {
		//gameObject.transform.position.x -= 0.2;

	}

	void AddCloud()
	{
		// Instantiate a random enemy.
		int enemyIndex = Random.Range(0, enemies.Length);
		Instantiate(enemies[enemyIndex], new Vector3(7,Random.Range(6.0f,10.0f),0), Quaternion.identity);
		// Play the spawning effect from all of the particle systems.
		/*foreach(ParticleSystem p in GetComponentsInChildren<ParticleSystem>())
		{
			p.Play();
		}*/
	}
}
